//
//  ZZBuyNowShopHeaderView.m
//  DistributorAB
//
//  Created by 主事丫环 on 2019/12/16.
//  Copyright © 2019 主事丫环. All rights reserved.
//

#import "ZZBuyNowShopHeaderView.h"

@implementation ZZBuyNowShopHeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupViewAction];
    }
    return self;
}
#pragma mark - 界面布局方法
- (void)setupViewAction{
    self.backgroundColor = kColorWithHex(0xffffff);
    
    UIButton *btnNew = [UIButton buttonWithType:UIButtonTypeCustom];
    btnNew.frame = CGRectMake(0, 10, KWIDTH/2, kScaleNum(122));
    btnNew.tag = 200;
    [btnNew setImage:imgname(@"order_mall_code_icon") forState:UIControlStateNormal];
    [btnNew addTarget:self action:@selector(btnClickAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btnNew];
    
    UIButton *btnBest = [UIButton buttonWithType:UIButtonTypeCustom];
    btnBest.frame = CGRectMake(btnNew.right, 10, KWIDTH/2, kScaleNum(122));
    btnBest.tag = 201;
    [btnBest setImage:imgname(@"lijiyuding") forState:UIControlStateNormal];
    [btnBest addTarget:self action:@selector(btnClickAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btnBest];
    
    UIButton *btnMulu = [UIButton buttonWithType:UIButtonTypeCustom];
    btnMulu.frame = CGRectMake(0, btnNew.bottom, KWIDTH/2, kScaleNum(122));
    btnMulu.tag = 202;
    [btnMulu setImage:imgname(@"houbaoyudingdan") forState:UIControlStateNormal];
    [btnMulu addTarget:self action:@selector(btnClickAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btnMulu];
    
    UIButton *btnOrder = [UIButton buttonWithType:UIButtonTypeCustom];
    btnOrder.frame = CGRectMake(btnMulu.right, btnBest.bottom, KWIDTH/2, kScaleNum(122));
    btnOrder.tag = 203;
    [btnOrder setImage:imgname(@"order_mall_apply_list_icon") forState:UIControlStateNormal];
    [btnOrder addTarget:self action:@selector(btnClickAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btnOrder];
    
    UIButton *btnList = [UIButton buttonWithType:UIButtonTypeCustom];
    btnList.frame = CGRectMake(0, btnMulu.bottom, KWIDTH/2, kScaleNum(122));
    btnList.tag = 204;
    [btnList setImage:imgname(@"yudingguanli") forState:UIControlStateNormal];
    [btnList addTarget:self action:@selector(btnClickAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btnList];
}
#pragma mark - 交互事件
- (void)btnClickAction:(UIButton *)sender{
    NSInteger tag = sender.tag;
    if (self.delegate && [self.delegate respondsToSelector:@selector(buyNowShopHeaderViewClick:)]) {
        if (tag == 200) {
            //扫码申请
            [self.delegate buyNowShopHeaderViewClick:ZBuyNowShopHeaderViewCategoryTypeSmsq];
        }else if (tag == 201){
            //立即预定
            [self.delegate buyNowShopHeaderViewClick:ZBuyNowShopHeaderViewCategoryTypeLjyd];
        }else if (tag == 202){
            //预定目录
            [self.delegate buyNowShopHeaderViewClick:ZBuyNowShopHeaderViewCategoryTypeYdml];
        }else if (tag == 203){
            //申请补助金
            [self.delegate buyNowShopHeaderViewClick:ZBuyNowShopHeaderViewCategoryTypeSqbzj];
        }else if (tag == 204){
            //预定管理
            [self.delegate buyNowShopHeaderViewClick:ZBuyNowShopHeaderViewCategoryTypeYdgl];
        }
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
